package Fzu.fh.domain.strategy.service.rule.tree.factory;

import Fzu.fh.domain.strategy.model.valobj.RuleLogicCheckTypeVO;
import Fzu.fh.domain.strategy.model.valobj.RuleTreeVO;
import Fzu.fh.domain.strategy.service.rule.chain.factory.DefaultChainFactory;
import Fzu.fh.domain.strategy.service.rule.tree.ILogicTreeNode;
import Fzu.fh.domain.strategy.service.rule.tree.factory.engine.IDecisionTreeEngine;
import Fzu.fh.domain.strategy.service.rule.tree.factory.engine.impl.DecisionTreeEngine;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.PackagePrivate;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @Author 冯昊
 * @description规则书工厂
 * @Date 2024/5/9  16:26
 */
@Service
public class DefaultTreeFactory {
    private final Map<String, ILogicTreeNode> logicTreeNodeGroup;

    public DefaultTreeFactory(Map<String, ILogicTreeNode> logicTreeNodeGroup) {
        this.logicTreeNodeGroup = logicTreeNodeGroup;
    }
    public IDecisionTreeEngine openLogicTree(RuleTreeVO ruleTreeVO){
        return new DecisionTreeEngine(logicTreeNodeGroup,ruleTreeVO);
    }
    @Data
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    public static class StrategyAwardVO{
        /** 抽奖奖品ID - 内部流转使用*/
        private Integer awardId;
        /** 抽奖奖品规则 */
        private String awardRuleValue;
    }
    @Data
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    public static class TreeActionEntity{
        private RuleLogicCheckTypeVO ruleLogicCheckType;
        private StrategyAwardVO strategyAwardVO;
    }
}
